# coding=utf-8
# __author__ = "James Zhang"
# !/usr/bin/python
# -*- coding: utf-8 -*-


class SettingError(Exception):
    """配置文件错误
    """


class ModelAttrDoesNotExist(Exception):
    """
    模型中不存在的属性
    """
    pass


class ImproperlyConfigured(Exception):
    """Tornado is somehow improperly configured"""
    pass


class TornadoRuntimeWarning(RuntimeWarning):
    pass


class ConnectionInterrumped(Exception):
    """Deprecated exception name with a typo."""

    def __init__(self, connection, parent=None):
        self.connection = connection
        self.parent = parent


class ConnectionInterrupted(ConnectionInterrumped):
    def __str__(self):
        error_type = "ConnectionInterrupted"
        error_msg = "An error occurred while connecting to redis"

        if self.parent:
            error_type = self.parent.__class__.__name__
            error_msg = str(self.parent)

        return "Redis %s: %s" % (error_type, error_msg)


class CompressorError(Exception):
    pass
